package router

import (
	"github.com/gin-gonic/gin"

	"mxshop-api/goods-web/api/goods"
	"mxshop-api/goods-web/global"
	"mxshop-api/shared/auth"
)

func InitGoodsRouter(Router *gin.RouterGroup) {
	signingKey := global.ServerConfig.SigningKey
	GoodsRouter := Router.Group("/goods")
	{
		GoodsRouter.GET("", goods.List)
		GoodsRouter.GET("/:id", goods.Detail)
		GoodsRouter.POST("", auth.Middleware(signingKey), auth.IsAdminUser(), goods.New)
		GoodsRouter.PUT("/:id", auth.Middleware(signingKey), auth.IsAdminUser(), goods.Update)
		GoodsRouter.PATCH("/:id", auth.Middleware(signingKey), auth.IsAdminUser(), goods.UpdateStatus)
		GoodsRouter.DELETE("/:id", auth.Middleware(signingKey), auth.IsAdminUser(), goods.Delete)
	}
}
